package com.ml.mall.service.variant.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ml.mall.entity.variant.SysProductVariantPic;
import com.ml.mall.mapper.variant.SysProductVariantPicMapper;
import com.ml.mall.service.variant.SysProductVariantPicService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
* <p>
    *  服务实现类
    * </p>
*
* @author kyyang
* Created 2021-05-15
*/
@Service
public class SysProductVariantPicServiceImpl extends ServiceImpl<SysProductVariantPicMapper, SysProductVariantPic> implements SysProductVariantPicService {

    @Autowired
    private  SysProductVariantPicMapper  sysProductVariantPicMapper;


    @Override
    public SysProductVariantPic selectPicByVariantIdOne(Long variantId) {
        QueryWrapper<SysProductVariantPic> w1 = new QueryWrapper<>();
        w1.eq("variant_id",variantId);
        w1.orderByAsc("`index`");
        List<SysProductVariantPic> sysProductVariantPics = sysProductVariantPicMapper.selectList(w1);
        if(sysProductVariantPics!=null&&sysProductVariantPics.size()>0){
            return sysProductVariantPics.get(0);
        }
        return null;
    }
}
